<?php
/**
 * 遮罩API
 *
 * 遮罩service
 *
 * @author    zhouchao <zhouchao@yunys.com.cn>
 * @copyright 2016 QuanZhouYunYiShang Inc.
 */
namespace App\Services\MasksService;

use App\Services\BaseService;
class MasksService extends BaseService
{
    /**
     * @param int $per_page
     * @return array
     */
    public function getMasks($per_page = 10){
        $this->setParameter([
            'table' => 'masks',
            'where' => [['state','=',1]],
            'select'=> ['mask_id','original_image','thumbnail','mask_preview_image'],
            'order' => 'created_at',
            'sort'  => 'desc'
        ]);
        $masks = $this->getAllPaginated($per_page)->toArray();
        foreach($masks['data'] as $mask){
            $mask->original_image = env('IMG_URL_STD_PREFIX').$mask->original_image;
            $mask->thumbnail = env('IMG_URL_STD_PREFIX').$mask->thumbnail;
            $mask->mask_preview_image = env('IMG_URL_STD_PREFIX').$mask->mask_preview_image;
        }
        $result = array('data'=>$masks['data'],'current_page'=>$masks['current_page'],'per_page'=>$per_page,'total_page'=>$masks['last_page']);
        return $this->createResult('M00000',$result);
    }
}